
import UIKit

class YYTabBarViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()


        //添加所有的子视图控制器
        addChildViewController()

        //自定义所有的子视图控制器
        let tabbar = YYTabBar()


        setValue(tabbar, forKey: "tabBar")


        let tabbarClosure = {

            YYPopView.testShow(self)
            print("界面跳转")
        }
        tabbar.closure = tabbarClosure
    }

    func addChildViewController(childController: UIViewController , title:String, image: String) {

        childController.title = title

        childController.tabBarItem.image = UIImage (named: image)

        childController.tabBarItem.selectedImage = UIImage(named: "\(image)_highlighted")

        addChildViewController(UINavigationController(rootViewController: childController))
    }

    func addChildViewController(){
        UITabBar.appearance().tintColor = UIColor.orangeColor()

        addChildViewController(YYHomeViewController(), title: "首页", image: "tabbar_home")

        addChildViewController(YYMessageViewController(), title: "消息", image: "tabbar_message_center")

        addChildViewController(YYFindViewController(), title: "发现", image: "tabbar_discover")

        addChildViewController(YYSettingViewController(), title: "设置", image: "tabbar_profile")
    }

}
